import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyJFrame implements ActionListener
{
    static boolean btStatus = true;
    JButton button;

    public static void main(String[] args) {
        MyJFrame gui = new MyJFrame();
        gui.go();
        System.out.println("End");
    }

    public void go() {
        JFrame frame = new JFrame();
        button = new JButton("Click me");

        button.addActionListener(this);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //click "X" to exit program
        frame.getContentPane().add(BorderLayout.EAST, button);
        frame.setSize(300,300);
        frame.setVisible(true);
    }

    public void actionPerformed(ActionEvent event) {
        if(btStatus) {
            button.setText("I've been clicked! 111");
            btStatus = false;
        }
        else {
            button.setText("I've been clicked! 222");
            btStatus = true;
        }
    }
}

class MyDrawPanel extends JPanel
{
    public void paintComponent(Graphics g) {
        g.setColor(Color.orange);
        g.fillRect(20,50,100,100);
    }
}